/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.object;


import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.api.Generator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.ContentGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.EndGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.VisibleGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.object.interfaces.Generatable;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.transformations.Showable;
import pl.edu.amu.wmi.kino.visualjavafx.model.objects.Canvas;
import pl.edu.amu.wmi.kino.visualjavafx.model.objects.ContentContainer;

/**
 *
 * @author Admin
 */
public class CanvasGenerator implements Generator,Generatable{

    @Override
    public boolean canGenerate(Object c) {
        if(c instanceof Canvas)
            return true;
        else return false;
    }

    @Override
    public void generate(StringBuilder sb, Object o,int recursionLevel,Object original) {
        this.generateStart(sb);
        this.generateUniqueAttributes(sb, (Canvas)o,recursionLevel);
        VisibleGenerator.generateVisibleAttribute(sb, recursionLevel);
        VisibleGenerator.generateVisibleVar(sb, (Showable)o, recursionLevel);
        ContentGenerator.generateContent(sb,(ContentContainer)o, recursionLevel,original);
        this.generateEnd(sb);
    }

    @Override
    public void generateStart(StringBuilder sb){
        sb.append("Canvas{\n");
    }
    @Override
    public void generateEnd(StringBuilder sb){
        EndGenerator.generateEnd(sb);
    }
    @Override
    public void generateUniqueAttributes(StringBuilder sb,Object o,int recursionLevel){
        Canvas c = (Canvas)o;
        int r=c.getBgColor().getRed();
        int g=c.getBgColor().getGreen();
        int b=c.getBgColor().getBlue();
        sb.append("background:Color.rgb("+r+","+g+","+b+");\n");
    }
}
